package com.zhongyouyun.utils;

import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class LongUtil {
    /**
     * 拼接部门sql
     *
     * @param LongList 部门ID列表
     * @return 拼接部门sql
     */
    public static String getDepartSqlStr(List<Long> LongList) {
        if (CollectionUtils.isEmpty(LongList)) {
            return null;
        }
        StringBuilder sql = new StringBuilder();
        LongList.forEach(data -> {
            sql.append("'").append(data).append("'").append(",");
        });

        sql.delete(sql.length() - 1, sql.length());
        return sql.toString();
    }

    public static List<Long> Longva(String[] childArr) {
        List<String> list = Arrays.stream(childArr).collect(Collectors.toList());
        List<Long> longList = new ArrayList<Long>();
        list.forEach(k -> {
            longList.add(Long.valueOf(k));
        });
        //查詢本部門和下級部門
//        Long id = deptModel.getId();
//        String fullPathId = deptModel.getFullPathId();
//        String childIds = fullPathId.substring(fullPathId.indexOf(id.toString()), fullPathId.length());
//        String[] childArr = childIds.split("/");
//        List<Long> list = (List<Long>) Arrays.stream(childArr);
        return longList;
    }
}
